<!--
 * @Description: In User Settings Edit
 * @Author: your name
 * @Date: 2019-08-28 13:56:04
 * @LastEditTime: 2019-08-29 09:22:43
 * @LastEditors: Please set LastEditors
 -->
<script>
	// 初始化 echarts 
	var demoChart = echarts.init(document.getElementById('realTimeInvoke'), 'macarons');
	demoChart.setOption({
		title: {
			text: '漏斗图',
			x: '80px',
			y: 'top',
			textAlign: 'center'
		},
		tooltip: {
			trigger: 'item',
			formatter: "{a} <br/>{b} : {c}%"
		},
		toolbox: {
			feature: {
				dataView: { readOnly: false },
				restore: {},
				saveAsImage: {}
			}
		},
		calculable: true,
	});
	demoChart.showLoading();

	//每秒执行定时器
	setInterval(function () {
		var seriesname = document.getElementsByName("tx_echarts_pi1[datas][name]");
		var legendval = document.getElementsByName("tx_echarts_pi1[datas][axis][]");
		var seriesval = document.getElementsByName("tx_echarts_pi1[datas][value][]");
		if (seriesname.length > 0 && legendval.length > 0 && seriesval.length > 0 && seriesname[0]!='' && legendval[0]!='' && seriesval[0]!='') {
			var legenddata = [];    //类别数组（实际用来盛放X轴坐标值）
			var seriesdata = [];    //销量数组（实际用来盛放Y坐标值）
			var seriesbum = [];    //销量数组（实际用来盛放Y坐标值）
			for (var i = 0; i < legendval.length; i++) {
				legenddata.push(legendval[i].value);
			}
			for (var j = 0; j < seriesval.length; j++) {
				var series = {};
				series.value= seriesval[j].value;
				series.name= legendval[j].value;
				seriesdata.push(series);
				seriesbum.push(seriesval[j].value);
			}

			demoChart.hideLoading();    //隐藏加载动画
			demoChart.setOption({
				legend: {
					top: 'bottom',
					data: legenddata
				},
				series: [
					{
						name: seriesname[0].value,
						type: 'funnel',
						left: '10%',
						top: 60,
						bottom: 60,
						width: '80%',
						min: 0,
						max: Math.max.apply(null, seriesbum),
						minSize: '0%',
						maxSize: '100%',
						sort: 'descending',
						gap: 2,
						label: {
							show: true,
							position: 'inside'
						},
						labelLine: {
							length: 10,
							lineStyle: {
								width: 1,
								type: 'solid'
							}
						},
						itemStyle: {
							borderColor: '#fff',
							borderWidth: 1
						},
						emphasis: {
							label: {
								fontSize: 20
							}
						},
						data: seriesdata
            		}
        		]
			});

		}
	}, 1000);

</script>